import request from '@/utils/request'

// 分页查询所有活动列表、或者查询某个社团的活动列表
export function findAllByPaging(params) {
  return request({
    url: '/leaves',
    method: 'get',
    params: params
  })
}
// 查询总记录条数
export function findTotal(params) {
  return request({
    url: '/leaves/total',
    method: 'get'
  })
}

// 管理员根据ID删除活动信息
export function removeById(leaveId) {
  return request({
    url: `/leaves/${leaveId}`,
    method: 'delete'
  })
}

// 管理员根据ID删除活动信息
export function approval(data) {
  return request({
    url: `/leaves/approval`,
    method: 'put',
    data
  })
}

// 发布活动、招新
export function add(data) {
  return request({
    url: '/leaves',
    method: 'post',
    data
  })
}

// 根据用户查询活动信息
export function findLeavesByUser(params) {
  return request({
    url: `/leaves/${params.userId}/${params.userType}/${params.leaveType}/${params.userCommunityId}`,
    method: 'get'
  })
}


// 用户报名参加活动
export function joinLeave(data) {
  return request({
    url: `/leaves/join`,
    method: 'post',
    data
  })
}

// 荍：分页查询所有请假列表
export function searchLeaveByPage(params) {
  return request({
    url: 'leaves/searchLeaveByPage',
    method: 'get',
    params: params
  })
}

// 荍：删除请假记录
export function deleteLeaveById(deleteId) {
    return request({
      url: `leaves/deleteLeaveById/${deleteId}`,
      method: 'post',
    })
  }

  // 荍：跟新请假记录
  export function updateLeaveInfo(data) {
    console.log(data);
    return request({
      url: 'leaves/updateLeaveInfo',
      method:'post',
      data
    })
  }

